﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataRepairRecord" @search="getTableDataRepairRecord">
      <el-row>
        
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="LineCode_FormItem" prop="LineCode" label="产线号">
            <el-input v-model="searchDataRepairRecord.LineCode" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="OperationCode_FormItem" prop="OperationCode" label="返修工序号">
            <el-input v-model="searchDataRepairRecord.OperationCode" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="OperationName_FormItem" prop="OperationName" label="返修工序名称">
            <el-input v-model="searchDataRepairRecord.OperationName" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="OldSN_FormItem" prop="OldSN" label="返修前SN">
            <el-input v-model="searchDataRepairRecord.OldSN" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="CurrentSN_FormItem" prop="CurrentSN" label="新SN">
            <el-input v-model="searchDataRepairRecord.CurrentSN" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="TZMaterialCode_FormItem" prop="TZMaterialCode" label="电机号">
            <el-input v-model="searchDataRepairRecord.TZMaterialCode" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="RepairStatus_FormItem" prop="RepairStatus" label="返修状态码">
            <el-input v-model="searchDataRepairRecord.RepairStatus" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Description_FormItem" prop="Description" label="返修信息描述">
            <el-input v-model="searchDataRepairRecord.Description" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="uploadTime_FormItem" prop="uploadTime" label="返修时间">
            <el-input v-model="searchDataRepairRecord.uploadTime" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="uploadFlag_FormItem" prop="uploadFlag" label="上传状态">
            <el-select v-model="searchDataRepairRecord.uploadFlag" clearable>
                <el-option :key="1" :value=true :label="$t('message._system.common.vm.tips_bool_true')"></el-option>
                <el-option :key="0" :value=false :label="$t('message._system.common.vm.tips_bool_false')"></el-option>
                </el-select>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Filed1_FormItem" prop="Filed1" label="预留域1">
            <el-input v-model="searchDataRepairRecord.Filed1" clearable></el-input>
        </el-form-item>
    </el-col>
    <el-col :xs="24" :lg="12" class="mb20">
        <el-form-item ref="Filed2_FormItem" prop="Filed2" label="预留域2">
            <el-input v-model="searchDataRepairRecord.Filed2" clearable></el-input>
        </el-form-item>
    </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/RepairRecord/Add'" icon='fa fa-plus' type='primary' :button-text="$t('message._system.common.vm.add')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/RepairRecord/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message._system.common.vm.batchdelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/RepairRecord/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message._system.common.vm.import')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/RepairRecord/RepairRecordExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message._system.common.vm.export')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefRepairRecord" v-bind="tableDataRepairRecord">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
          <el-button text type="primary" @click="OnEditrowClick(scope.row)" v-auth="'/api/RepairRecord/Edit'">{{ $t('message._system.common.vm.edit') }}</el-button>
					<el-button text type="primary" @click="OnDetailsrowClick(scope.row)" v-auth="'/api/RepairRecord/{id}'">{{ $t('message._system.common.vm.detail') }}</el-button>
					<el-popconfirm :title="$t('message._system.common.vm.deletetip')"  @confirm="onDelete(scope.row)">
						<template #reference>
							<el-button text type="danger" v-auth="'/api/RepairRecord/BatchDelete'">{{ $t('message._system.common.vm.delete') }}</el-button>
						</template>
					</el-popconfirm>
        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="返修信息记录表;true;TyMES.Controllers;RepairRecord">
import {  ElMessageBox, ElMessage } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { RepairRecordApi } from '/@/api/record/RepairRecord';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateRepairRecord = reactive({
    
});

const searchDataRepairRecord = ref({
    			LineCode: null,
			OperationCode: null,
			OperationName: null,
			OldSN: null,
			CurrentSN: null,
			TZMaterialCode: null,
			RepairStatus: null,
			Description: null,
			uploadTime: null,
			uploadFlag: null,
			Filed1: null,
			Filed2: null,

});

// 定义变量内容
const tableRefRepairRecord = ref();
const tableDataRepairRecord = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
  
        {title:'产线号',key: 'LineCode',type: 'text',isCheck: true},
        {title:'返修工序号',key: 'OperationCode',type: 'text',isCheck: true},
        {title:'返修工序名称',key: 'OperationName',type: 'text',isCheck: true},
        {title:'返修前SN',key: 'OldSN',type: 'text',isCheck: true},
        {title:'新SN',key: 'CurrentSN',type: 'text',isCheck: true},
        {title:'电机号',key: 'TZMaterialCode',type: 'text',isCheck: true},
        {title:'返修状态码',key: 'RepairStatus',type: 'text',isCheck: true},
        {title:'返修信息描述',key: 'Description',type: 'text',isCheck: true},
        {title:'返修时间',key: 'uploadTime',type: 'text',isCheck: true},
        {title:'上传状态',key: 'uploadFlag',type: 'switch',isCheck: true},
        {title:'预留域1',key: 'Filed1',type: 'text',isCheck: true},
        {title:'预留域2',key: 'Filed2',type: 'text',isCheck: true},
	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataRepairRecord = () => {
    tableRefRepairRecord.value.doSearch(RepairRecordApi().search, searchDataRepairRecord.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message._system.common.vm.add'), CreateDialog, null, getTableDataRepairRecord)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message._system.common.vm.edit'), EditDialog, row, getTableDataRepairRecord)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message._system.common.vm.detail'), DetailsDialog, row, getTableDataRepairRecord)
};

// 删除
const onDelete = (row: any) => {
    RepairRecordApi().delete([row.ID]).then(() => { getTableDataRepairRecord()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefRepairRecord.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      RepairRecordApi().delete(selectedids).then(() => { getTableDataRepairRecord()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message._system.common.vm.import'), ImportDialog, null, getTableDataRepairRecord)
};

const onExport = () => {
	const selected = tableRefRepairRecord.value.getSelectedRows();
	if (selected.length > 0) {
		RepairRecordApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		RepairRecordApi().export({});
	}
};

// 页面加载时
onMounted(() => {
     
        getTableDataRepairRecord();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

